import { request } from "../request";
import { API, ADMINAPI } from "../const";

export function login({ username, password }) {
  return request({
    url: `${API}/user/login`,
    method: "post",
    data: {
      username,
      password,
    },
  });
}

export function register({ username, password, role }) {
  return request({
    url: `${ADMINAPI}/user`,
    method: "post",
    data: {
      username,
      password,
      role,
    },
  });
}

export function updatePassword({ password }) {
  return request({
    url: `${ADMINAPI}/user`,
    method: "put",
    data: {
      password,
    },
  });
}


export function getAduitStatus() {
  return request({
    url: `${ADMINAPI}/user`,
    method: "get",
  });
}


export function getUserList(data = {}) {
  return request({
    url: `${ADMINAPI}/user/list`,
    data: {
      role: data?.role,
      shop_id: data?.shop_id,
      is_visit: data?.is_visit,
    },
  });
}

export function deleteSuperAdmin(id) {
  return request({
    url: `${ADMINAPI}/user/${id}`,
    method: "delete",
  });
}

export function aduitSuperAdmin(id, status) {
  return request({
    url: `${ADMINAPI}/user/${id}`,
    method: "post",
    data: {
      status,
    },
  });

}
